package com.d0317;

import java.util.Scanner;

import static java.lang.Thread.sleep;

public class StopIOWaitThread {
    public static void main(String[] args) {
        IOWaitThread stopIOWaitThread = new IOWaitThread();
        System.out.println("启动");
        stopIOWaitThread.start();
//        try {
//            sleep(100);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        stopIOWaitThread.interrupt();//不能中断
//        StopIOWaitThread.scanner.close();
    }
}

class IOWaitThread extends Thread{
    Scanner scanner = new Scanner(System.in);
    private boolean flag = true;

    @Override
    public void run(){
        while (flag){
            try {
                System.out.println("等待输入");
            }catch (Exception ex){

            }
            scanner.nextLine();
        }
    }
    public void stopThread(){
        flag = false;
    }
}
